package controller.admin.setmeal;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import model.DTO.SetmealAddDTO;
import model.DTO.SetmealEditDTO;
import service.Impl.SetmealServiceImpl;
import util.GetJsonUtil;
import util.ResultUtil;

import java.io.IOException;

@WebServlet("/admin/setmeal/add")
public class SetmealCreateController extends HttpServlet {
    //新增套餐
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        SetmealAddDTO saD=new SetmealAddDTO();
//        SetmealServiceImpl ss=new SetmealServiceImpl();
//        saD.setCategoryId(Integer.parseInt(req.getParameter("categoryId")));
//        saD.setDescription(req.getParameter("description"));
//        saD.setImage(req.getParameter("image"));
//        saD.setName(req.getParameter("name"));
//        saD.setPrice(Double.parseDouble(req.getParameter("price")));
//        saD.setStatus(Integer.parseInt(req.getParameter("status")));
        SetmealAddDTO saD= (SetmealAddDTO) GetJsonUtil.get(req,new SetmealAddDTO());
        SetmealServiceImpl ss=new SetmealServiceImpl();
        ss.add(saD);
        String json= ResultUtil.getJSON(null);
        resp.getWriter().println(json);
    }
}
